import request from "@/request";
import ApiResponse from "../common/api-response.ts";
import { FlexChatResponse, sessionRecordListData } from "./flex-chat-response";
import { SessionRecord } from "@/api/chat/session-record";
import { SessionRecordReq } from "@/api/chat/session-record-req";
export default class ChatApi {
  static async getChatRecord(
    requestId: string
  ): Promise<ApiResponse<FlexChatResponse[]>> {
    return ApiResponse.fromResponse(
      await request.get(`/chatRecord/list/${requestId}`)
    );
  }

  static async getSessionRecord(
    params: sessionRecordListData
  ): Promise<ApiResponse<SessionRecord[]>> {
    return ApiResponse.fromResponse(
      await request.get("/sessionRecord/list", {
        params,
      })
    );
  }

  // 创建或修改
  static async createOrUpdateSessionRecord(
    data: SessionRecordReq
  ): Promise<ApiResponse<void>> {
    return ApiResponse.fromResponse(
      await request.post("/sessionRecord/saveOrUpdate", data)
    );
  }

  static async getpromptTemplate(): Promise<ApiResponse<void>> {
    return ApiResponse.fromResponse(await request.get("/promptTemplate/list"));
  }

  // 保存或者更新模板
  static async saveOrUpdatePromptTemplate(data: {
    content: string;
  }): Promise<ApiResponse<void>> {
    return ApiResponse.fromResponse(
      await request.post("/promptTemplate/saveOrUpdate", data)
    );
  }
}
